package easy;

public class Solution_1290 {

    public int getDecimalValue(ListNode head) {
        int num = 0;
        while (head != null) {
            num <<= 1;
            num += head.val;
            head = head.next;
        }
        return num;
    }

    public static void main(String[] args) {
        Solution_1290 model = new Solution_1290();
        ListNode node = new ListNode(0);
        node.next = new ListNode(0);
        node.next.next = new ListNode(1);
        System.out.println(model.getDecimalValue(node));
    }

    static class ListNode {

        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }
}
